import { defineStore } from 'pinia'
import { reqC2List, reqC1List, reqC3List } from '@/api/product/attr/attr'
import type { categoryStoreStateType } from './interface/category';
const useCategory = defineStore('category', {
    state: (): categoryStoreStateType => ({
        C1List: [],
        C2List: [],
        C3List: [],
        c1Id: '',
        c2Id: '',
        c3Id: ''

    }),
    actions: {
        async getcategory() {
            let result = await reqC1List()
            this.C1List = result
        },
        async getC2List() {
            this.C2List = []
            this.C3List = []
            this.c2Id = ''
            this.c3Id = ''
            let result = await reqC2List(this.c1Id)
            this.C2List = result
        },
        async getC3List() {
            this.C3List = []
            this.c3Id = ''
            let result = await reqC3List(this.c2Id)
            this.C3List = result
        }

    }
})
export default useCategory